package priv.pattern.responsibility.service.impl;

import priv.pattern.responsibility.pojo.ResponsibilityEnum;
import priv.pattern.responsibility.service.Handler;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Objects;

/*
 * 作者：m鹏h
 * 时间；2024/5/31 23:16
 * 描述：Ceo的职责
 **/
public class CeoImpl extends Handler {
    //职责
    Integer[] myResponsibility = {ResponsibilityEnum.APPLICATION_FOR_CHANGE_OF_OFFICE.getCode(), ResponsibilityEnum.APPLICATION_FOR_RESIGNATION.getCode()};

    @Override
    public String isResponsble(Integer code) {
        if (Arrays.asList(myResponsibility).contains(code)) {
            ResponsibilityEnum typeByCode = ResponsibilityEnum.findTypeByCode(code);
            if (typeByCode != null) {
                switch (typeByCode) {
                    case APPLICATION_FOR_CHANGE_OF_OFFICE:
                        System.out.println("我是CEO,我批准你去更换办公司");
                        break;
                    case APPLICATION_FOR_RESIGNATION:
                        System.out.println("我是CEO,我批准你离职");
                        break;
                    default:
                        throw new IllegalStateException("CEO Unexpected value: " + code);
                }
            }
            return null;
        } else {
            System.out.println("我是CEO ,这些申请不归我管！！！");
        }
        return null;
    }
}
